//
//  MYChooseContrllerTool.m
//  奇闻
//
//  Created by 似水灵修 on 14-11-26.
//  Copyright (c) 2014年 MingYueGuCheng. All rights reserved.
// 

#import "MYChooseContrllerTool.h"
#import "MYTabBarController.h"
#import "MYNewFeatureCollectionViewController.h"

@implementation MYChooseContrllerTool
+ (void)chooseRootViewController:(UIWindow *)window
{
    //判断是否有新特性
    //当前版本号
    NSString *versionKey = (__bridge NSString*)kCFBundleVersionKey;
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[versionKey];
    //上一次使用版本号
    NSString *lastVersion = [MYUserDefaults objectForKey:versionKey];
    if (![currentVersion isEqualToString:lastVersion]) {//有新特性
        MYNewFeatureCollectionViewController *newFeatureVC = [[MYNewFeatureCollectionViewController alloc] init];
        window.rootViewController = newFeatureVC;
        //存储新版本特性
        [MYUserDefaults setObject:currentVersion forKey:versionKey];
        [MYUserDefaults synchronize];
    }
    else {//无新特性
        MYTabBarController *tabBarVC = [[MYTabBarController alloc] init];
        window.rootViewController = tabBarVC;
    }
}
@end
